<template>
  <div class="Big-box">
    <Header title="动火方案"></Header>
    <!-- <div class="box">
      <div class="small p-10" @click="Click">动火方案列表</div>
     
    </div> -->
    <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
      >
        <van-cell
          v-for="(item, index) in list"
          :key="index"
          @click="ProjectPlan(item)"
        >
          {{ item.name }}
        </van-cell>
      </van-list>
    </van-pull-refresh>
  </div>
</template>

<script>
import { Hotlist } from "@/api/hotworkplan";
export default {
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
      refreshing: false,
      userId: localStorage.getItem("userId"),
    };
  },

  methods: {
    onLoad() {
      setTimeout(() => {
        if (this.refreshing) {
          this.list = [];
          this.refreshing = false;
        }

        // for (let i = 0; i < 10; i++) {
        //   this.list.push(this.list.length + 1);
        // }
        this.loading = false;

        if (this.list.length >= 40) {
          this.finished = true;
        }
      }, 1000);
    },
    onRefresh() {
      // 清空列表数据
      this.finished = false;

      // 重新加载数据
      // 将 loading 设置为 true，表示处于加载状态
      this.loading = true;
      this.onLoad();
    },
    onLoad() {
      this.refreshing = false;
      this.finished = true;
    },
    ProjectPlan(val) {
      // console.log(val.id);
      this.$router.push({
        path: "/details",
        query: {
          id: val.id,
        },
      });
    },
  },

  mounted() {
    let params = {
      d: {
        c: [
          {
            key: "spaceId",
            value: sessionStorage.getItem("projectspaceId"),
          },
          {
            key: "entSpaceId",
            value: sessionStorage.getItem("enterprise"),
          },
          {
            key: "userId",
            value: localStorage.getItem("userId"),
          },
          {
            key: "authToken",
            value: localStorage.getItem("authToken"),
          },
        ],
        filters: [
          {
            field: "confirmUserIds",
            operator: "like",
            value: this.userId,
            value: null,
          },
          {
            field: "st",
            operator: "NE",
            value: 9,
          },
        ],
      },
    };
    Hotlist(params).then((res) => {
      // console.log(res.data.result);
      this.list = res.data.result;
    });
  },
  onClick() {
    this.$router.push("/workcontext");
  },
};
</script>

<style lang="scss" scoped>
.Big-box {
  width: 100%;
  background-color: #f3f4f8;
  .small {
    height: 0.3rem;
    line-height: 0.3rem;
    margin: 0.1rem 0;
    background-color: #ffffff;
  }
  .van-cell {
    margin: 0.05rem 0;
  }
}
</style>

